import { createStore, applyMiddleware } from 'redux';
import rootReducer from '../reducers';
import thunk from 'redux-thunk';
import {
    composeWithDevTools
} from 'redux-devtools-extension';
import reduxAxios from '../reducers/middleware/reduxAxios.js';

//定义中间件数组
const middlewares = [];

//1.存放redux-thunk中间件,可以替换成redux-saga
middlewares.push(thunk);
//2.存放异步中间件
middlewares.push(reduxAxios);

export default function configureStore(initialState) {
    const store = createStore(rootReducer, initialState,
        composeWithDevTools(applyMiddleware(...middlewares)));
    return store;
}